﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ListBookActive.ascx.cs" Inherits="Controls_ListBookActive" %>
<script type="text/javascript">

    function confirmation(BookID) {
	    var err = "<%=deletecf%>";
        var answer = confirm(err);
	    if (answer){
	        window.location = "Delete.aspx?bookid=" + BookID;
	    }
	}
	function CheckActiveAll(check) {
	    if (check.checked) {
	        $("input.checkItem").attr('checked', 'checked');
	    }
	    else {
	        $("input.checkItem").attr('checked', '');
	    }
	}
</script>
<%if (listBook.Count > 0)
  {%>
<table class="TableBooks" id="tablepaging">
    <thead>
        <th class="Width80" style="color: white"><%= Language["Name"]%></th>
        <th class="Width150" style="color: white"><%= Language["Photo"]%></th>
        <th class="Width100" style="color: white"><%= Language["Downloaded"]%></th>
        <th class="Width80" style="color: white"><%= Language["Date"]%></th>
        <th class="Width80" style="color: white"><%= Language["Active"]%></th>
        <th class="Width80" style="color: white"><input type="checkbox" onchange="CheckActiveAll(this)" id="checkActiveAll"/></th>
    </thead>
    <tbody>
            <%
      for (int i = 0; i < listBook.Count; i = i + 1)
      {
          if (i % 2 == 0)
          {%>
                    <tr class="Even">
                        <td><%= listBook[i].Name%></td>
                        <td><a href="../Home/BookDetail.aspx?bookid=<%= listBook[i].ID %>"><img src="..<%= listBook[i].Image %>" width="107px" height="147px"></a></td>
                        <td><%= listBook[i].NumberOfDownload%></td>
                        <td><%= listBook[i].DateUpload%></td>
                        <td><%= ConvertActive((bool)listBook[i].Active)%></td>
                        <td class="Action">
                            <input type="checkbox" name="checkItem_<%= listBook[i].ID %>" class="checkItem"/>
                        </td>
                    </tr>
            <%
          }
          else
          {
%>
                    <tr class="Odd">
                       <td><%= listBook[i].Name%></td>
                       <td><a href="../Home/BookDetail.aspx?bookid=<%= listBook[i].ID %>"><img src="..<%= listBook[i].Image %>" width="107px" height="147px"></a></td>
                        <td><%= listBook[i].NumberOfDownload%></td>
                        <td><%= listBook[i].DateUpload%></td>
                        <td><%= ConvertActive((bool)listBook[i].Active)%></td>
                        <td class="Action">
                           <input type="checkbox" name="checkItem_<%= listBook[i].ID %>" class="checkItem"/>
                        </td>
                    </tr>           
            <%
          }
      }
%>
    </tbody>
</table>
<%if (listBook.Count > 20) {%>
<div id="pageNavPosition" style="padding-top: 20px; text-align:left; float: left; width: 100%;" align="center"></div>
 <script type="text/javascript">

     var pager = new Pager('tablepaging', 20);
     pager.init();
     pager.showPageNav('pager', 'pageNavPosition');
     pager.showPage(1);  

</script>
<%} %>
<% } else{%>
<p class="NoResult">
    <%=Language["noresult"]%>
</p>
<%} %>